package com.my.note.mapper;

import com.my.note.pojo.ResourceData;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

/**
 * @author lilun <a href="mailto:lil@chsi.com.cn">lilun</a>
 * @version $Id$ 2019年03月20 16:22
 */
@Mapper
@Component
public interface ResourceMapper {

    @Select("select * from NOTE_RESOURCE where url = #{url}")
    ResourceData getResourceByUrl(@Param(value = "url") String url);

    @Select("select * from NOTE_RESOURCE where id = #{id}")
    ResourceData getResourceById(@Param(value = "id") String id);

    @Select("select * from NOTE_RESOURCE")
    List<ResourceData> getResouceList();

    @Insert("insert into NOTE_RESOURCE(id,url,mark) values(#{id},#{url},#{mark})")
    void saveResource(@Param("id") String id, @Param("url") String url, @Param("mark") String mark);

    @Delete("delete from NOTE_RESOURCE where id=#{id}")
    void deleteResource(@Param("id") String id);
}